package com.ssy.lingxi.purchase.controller.purchase;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.purchase.api.dto.request.*;
import com.ssy.lingxi.purchase.api.dto.request.purchase.PurchaseInquiryListRequest;
import com.ssy.lingxi.purchase.api.dto.request.purchase.QuotedPriceInfoRequest;
import com.ssy.lingxi.purchase.api.dto.response.BiddingExternalWorkStateEnumResponse;
import com.ssy.lingxi.purchase.api.dto.response.PriceParityDetailsResponse;
import com.ssy.lingxi.purchase.api.dto.response.purchase.*;
import com.ssy.lingxi.purchase.service.ConfirmQuotedPriceService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 采购能力-确认报价
 * @author wrc
 * @date 2021/1/9
 */
@RestController
@RequestMapping("/purchase/confirm/quoted/price")
public class ConfirmQuotedPriceController extends BaseController {

    @Resource
    ConfirmQuotedPriceService confirmQuotedPriceService;

    /**
     *报价查询
     */
    @GetMapping("/list")
    public Wrapper<PageData<PurchaseInquiryListResponse>> list(PurchaseInquiryListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.list(request,sysUser);
    }

    /**
     *调整报价截止时间
     */
    @PostMapping("/adjust/time")
    public Wrapper adjustTime(@Valid  @RequestBody AdjustTimeRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.adjustTime(request,sysUser);
    }

    /**
     *报价详情
     */
    @GetMapping("/details")
    public Wrapper<ConfirmQuotedPriceResponse> details(@Valid  ConfirmQuotedPriceDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.details(request,sysUser);
    }

    /**
     *立即比价
     */
    @GetMapping("/right/off/contrast/price")
    public Wrapper<List<PriceParityDetailsResponse>> rightOffContrastPrice(@Valid  ConfirmQuotedPriceDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.rightOffContrastPrice(request,sysUser);
    }

    /**
     *报价单详情-物料详情列表分页查询
     */
    @GetMapping("/materiel/detailed")
    public Wrapper<PageData<QuotedPriceProductResponse>> materielDetailed(@Valid  MaterielDetailedRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.materielDetailed(request,sysUser);
    }

    /**
     * 报价单详情
     */
    @GetMapping("/order/details")
    public Wrapper<ConfirmQuotedPriceDetailsResponse> orderDetails(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.detailed(request,sysUser);
    }

    /**
     *待比价
     */
    @GetMapping("/stay/contrast/price")
    public Wrapper<PageData<PurchaseInquiryListResponse>> stayContrastPrice(PurchaseInquiryListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayContrastPrice(request,sysUser);
    }

    /**
     *发起下轮报价
     */
    @PostMapping("/launch/turn/quoted/price")
    public Wrapper launchTurnQuotedPrice(@Valid @RequestBody AdjustTimeRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.launchTurnQuotedPrice(request,sysUser);
    }

    /**
     *解密报价单
     */
    @PostMapping("/decrypt/quoted/price")
    public Wrapper decryptQuotedPrice(@Valid @RequestBody DecryptQuotedPriceRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.decryptQuotedPrice(request,sysUser);
    }

    /**
     *提交比价
     */
    @PostMapping("/submit/contrast/price")
    public Wrapper submitContrastPrice(@Valid @RequestBody SubmitContrastPriceRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.submitContrastPrice(request,sysUser);
    }

    /**
     *待审核授标结果(一级)
     */
    @GetMapping("/stay/examine/award1/list")
    public Wrapper<PageData<PurchaseInquiryListResponse>> stayExamineAward1List(PurchaseInquiryListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayExamineAward1List(request,sysUser);
    }

    /**
     *审核授标结果(一级)
     */
    @PostMapping("/stay/examine/award1")
    public Wrapper stayExamineAward1(@Valid @RequestBody BaseExamineRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayExamineAward1(request,sysUser);
    }

    /**
     *批量审核授标结果(一级)
     */
    @PostMapping("/stay/examine/awards1")
    public Wrapper stayExamineAwards1(@Valid @RequestBody BaseAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayExamineAwards1(request,sysUser);
    }

    /**
     *待审核授标结果(二级)
     */
    @GetMapping("/stay/examine/award2/list")
    public Wrapper<PageData<PurchaseInquiryListResponse>> stayExamineAward2List(PurchaseInquiryListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayExamineAward2List(request,sysUser);
    }

    /**
     *审核授标结果(二级)
     */
    @PostMapping("/stay/examine/award2")
    public Wrapper stayExamineAward2(@Valid @RequestBody BaseExamineRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayExamineAward2(request,sysUser);
    }

    /**
     *批量审核授标结果(二级)
     */
    @PostMapping("/stay/examine/awards2")
    public Wrapper stayExamineAwards2(@Valid @RequestBody BaseAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayExamineAwards2(request,sysUser);
    }

    /**
     *待确认授标结果
     */
    @GetMapping("/stay/confirm/award/result/list")
    public Wrapper<PageData<PurchaseInquiryListResponse>> stayConfirmAwardResultList(PurchaseInquiryListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayConfirmAwardResultList(request,sysUser);
    }

    /**
     *确认授标结果
     */
    @PostMapping("/stay/confirm/award/result")
    public Wrapper stayConfirmAwardResult(@Valid @RequestBody BaseExamineRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.stayConfirmAwardResult(request,sysUser);
    }

    /**
     *报价供应商信息
     */
    @GetMapping("/quoted/price/info")
    public Wrapper<PageData<QuotedPriceInfoResponse>> quotedPriceInfoList(@Validated QuotedPriceInfoRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return confirmQuotedPriceService.quotedPriceInfoList(request,sysUser);
    }

    /**
     * 采购确认报价单工作流内部状态枚举
     */
    @GetMapping("/interior/status")
    public Wrapper<List<BiddingExternalWorkStateEnumResponse>> interiorStatus() {
        return confirmQuotedPriceService.interiorStatus();
    }
}
